package com.cgrs572.shortlink.project.common.convention.exception;

import com.cgrs572.shortlink.project.common.convention.errorcode.BaseErrorCode;
import com.cgrs572.shortlink.project.common.convention.errorcode.IErrorCode;

/**
 * 客户端异常
 */
public class ClientException extends AbstractException {
    /**
     * 返回详细宏观码，只需传入枚举类中的对应枚举即可
     * @param errorCode
     */
    public ClientException(IErrorCode errorCode) {
        this(null, null, errorCode);
    }

    /**
     * 返回一级错误宏观码,只需传入message错误信息即可
     * @param message
     */
    public ClientException(String message) {
        this(message, null, BaseErrorCode.CLIENT_ERROR);
    }

    /**
     * 返回详细宏观码，但想要自定义枚举类中对应枚举的错误信息
     * @param message
     * @param errorCode
     */
    public ClientException(String message, IErrorCode errorCode) {
        this(message, null, errorCode);
    }

    /**
     * 以上三种构造器均调会自动用该构造器
     * @param message
     * @param throwable
     * @param errorCode
     */
    public ClientException(String message, Throwable throwable, IErrorCode errorCode) {
        super(message, throwable, errorCode);
    }

    @Override
    public String toString() {
        return "ClientException{" +
                "code='" + errorCode + "'," +
                "message='" + errorMessage + "'" +
                '}';
    }
}

